package com.lms.generictype.demo4;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

/**
 * @Author: 李孟帅
 * @CreateTime: 2020-01-16 17:10
 * @Description:  泛型擦除
 */
public class Test {
    public static void main(String[] args) {
        Class<Computer> computerClass = Computer.class;
        get(computerClass);
        System.out.println("------------------");
        Class<Iphone> iphoneClass = Iphone.class;
       get(iphoneClass);
        System.out.println("---------------");
        Class<Product> productClass = Product.class;
       get(productClass);
    }
    public static void get(Class clz){
        Field[] declaredFields = clz.getDeclaredFields();
        for (Field declaredField : declaredFields) {
            System.out.println("属性名："+declaredField.getName()+"，类型："+declaredField.getType().getSimpleName());
        }
        Method[] declaredMethods = clz.getDeclaredMethods();
        for (Method declaredMethod : declaredMethods) {
            System.out.println("方法名："+declaredMethod.getName()+",返回类型："+declaredMethod.getReturnType().getSimpleName());
        }
    }
}
